package ua.tach.shortl;

import ua.tach.shortl.logic.Country;
import ua.tach.shortl.screens.*;

import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;

public class Shortl implements ApplicationListener {
	private boolean isInitialized = false;
	private Screen screen;

	@Override public void dispose () {

	}

	@Override public void render () {
		Application app = Gdx.app;

		// update the screen
		screen.update(app);

		// render the screen
		screen.render(app);

		// when the screen is done we change to the
		// next screen
		if (screen.isDone()) {
			// dispose the current screen
			screen.dispose();

			// if this screen is a main menu screen we switch to
			// the game loop
			if (screen instanceof MainMenu)
				screen = new GameLoop(app);
			else
			// if this screen is a game loop screen we switch to the
			// game over screen
			if (screen instanceof GameLoop)
				screen = new MainMenu(app);
		}
	}

	@Override public void resize (int width, int height) {

	}

	@Override public void create () {
		if (!isInitialized) {
			// init globals
			new TextureLoader();
			new Country(Gdx.app);
			Country.enableSound = false;

			//screen = new MainMenu(Gdx.app); 
			screen = new GameLoop(Gdx.app);
			isInitialized = true;
			
		}
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
		System.out.println("resume");
	}
}
